<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title>珠珠儿设置</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="../../layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="../../css/public.css">
</head>

<body class="tbody">
	<form class="layui-form layui-form-pane layui-container layui-col-space10" lay-filter="dataform">
		<input type="text" class="layui-input" autocomplete="off" name="id" style="display: none;">
		<div style="width:500px;">
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">拍卖保证金（元）</label>
				<div class="layui-input-block">
					<input type="text" class="layui-input" autocomplete="off" name="security_fund"
						lay-verify="numberInt"></input>
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">珠珠儿中拍后商品冻结时间（小时）</label>
				<div class="layui-input-block">
					<input type="text" class="layui-input" autocomplete="off" name="robot_auction_freeze"
						lay-verify="numberInt"></input>
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">九宫格抽奖游戏，珠珠儿排队条件（用户排队人数小于x）</label>
				<div class="layui-input-block">
					<input type="text" class="layui-input" autocomplete="off" name="dial_condition_number"
						lay-verify="numberInt"></input>
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">九宫格抽奖游戏，珠珠儿不排队条件（用户排队人数大于x）</label>
				<div class="layui-input-block">
					<input type="text" class="layui-input" autocomplete="off" name="dial_condition_number_max"
						lay-verify="numberInt"></input>
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">九宫格抽奖游戏，珠珠儿排队间隔时间（最小）</label>
				<div class="layui-input-block">
					<input type="text" class="layui-input" autocomplete="off" name="dial_min_interval"
						lay-verify="numberInt"></input>
				</div>
			</div>
			<div class="layui-form-item layui-form-text">
				<label class="layui-form-label">九宫格抽奖游戏，珠珠儿排队间隔时间（最大）</label>
				<div class="layui-input-block">
					<input type="text" class="layui-input" autocomplete="off" name="dial_max_interval"
						lay-verify="numberInt"></input>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block" style="float:right;">
					<button class="layui-btn" lay-submit="" lay-filter="save">确定</button>
				</div>
			</div>
		</div>
	</form>
	<script type="text/javascript" src="../../layui/layui.js"></script>
	<script type="text/javascript" src="../../js/jsCtl.js"></script>
	<script>
		layui.use(['form', 'layer'], function () {
			var form = layui.form,
				$ = layui.jquery;

			let data = {};
			(async function () {
				let res = await ajaxAsyncNoTip('robot/config');
				res.forEach(element => {
					data[element.item] = element.val;
				});
				form.val("dataform", JSON.parse(JSON.stringify(data)));
			})()

			form.verify({
				numberInt: function (value, item) { //value：表单的值、item：表单的DOM对象
					if (!/^\+?[1-9]\d*$/.test(value)) {
						return '请输入大于0的正整数';
					}
				}
			});

			//监听提交
			form.on("submit(save)", element => {
				(async function () {
					let data = form.val("dataform");
					await ajaxAsync('robot/config', data, 'PUT');
				})()
				return false;
			});

		});
	</script>
</body>

</html>